/** 
  考核指标表
*/
<template>
  <div>
    <table class="table-style-baseinfos">
      <tbody>
        <tr>
          <td class="text-right-background-color">{{ $t('templateSetting.templateName') }}:</td>
          <td class="text-left-background-none">{{ dataListProp.templateName }}</td>
          <td class="text-right-background-color">{{ $t('templateSetting.baseLevel') }}:</td>
          <td class="text-left-background-none">{{ dataListProp.baseLevel | baseLevel }}</td>
        </tr>
        <tr>
          <td class="text-right-background-color">{{ $t('templateSetting.description') }}:</td>
          <td class="text-left-background-none" colspan="3">{{ dataListProp.description }}</td>
        </tr>
      </tbody>
    </table>
    <table class="table-style-baseinfo">
      <thead>
        <tr>
          <th class="text-center-background-color">{{ $t('asesmentSetting.assessmentIndex') }}</th>
          <th class="text-center-background-color">{{ $t('asesmentSetting.assessmentIndexDesc') }}</th>
          <th v-if="showWeight" class="text-center-background-color">{{ $t('asesmentSetting.assessmentIndexWeig') }}</th>
          <th class="text-center-background-color">{{ $t('asesmentSetting.assessmentDetails') }}</th>
          <th class="text-center-background-color">{{ $t('asesmentSetting.assessmentDetailsDesc') }}</th>
          <th v-if="showWeight" class="text-center-background-color">{{ $t('asesmentSetting.assessmentDetailsWeig') }}</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in tableData" :key="index">
          <td v-if="item.subCount" :rowspan="item.subCount" class="text-center-background">{{ item.itemName }}</td>
          <td v-if="item.subCount" :rowspan="item.subCount" class="text-center-background">{{ item.itemDescription }}</td>
          <td v-if="item.subCount && showWeight" :rowspan="item.subCount" class="text-center-background">{{ item.itemWeight }}</td>
          <td class="text-center-background">{{ item.detailName }}</td>
          <td class="text-center-background">{{ item.detailDescription }}</td>
          <td v-if="showWeight" class="text-center-background">{{ item.detailWeight }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
export default {
  props: {
    dataListProp: {
      type: Object,
      default: () => {}
    },
    showFlag: {
      type: Boolean,
      default: false
    },
    showWeight: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      tableData: []
    }
  },
  filters: {
    baseLevel(val) {
      switch (val) {
        case '1':
          return '校级'
        case '2':
          return '院级'
        default:
          return val
      }
    }
  },
  created() {
    
  },
  mounted() {
  },
  methods: {
    
  },
  watch: {
    dataListProp: {
      handler(newVal) {
        if (newVal.itemList && Array.isArray(newVal.itemList) && newVal.itemList.length > 0) {
          newVal.itemList.map((item, index) => {
            if (item.detailList.length > 0) {
              item.detailList.map((subItem, subIndex, subArray) => {
                if (subIndex === 0) {
                  subItem['itemName'] = item.itemName;
                  subItem['itemDescription'] = item.itemDescription;
                  subItem['itemWeight'] = item.itemWeight;
                  subItem['subCount'] = subArray.length;
                }
                this.tableData.push(subItem);
              });
            } else {
              item['detailName'] = '';
              item['detailDescription'] = '';
              item['detailWeight'] = '';
              item['subCount'] = 1;
              delete item.detailList;
              this.tableData.push(item);
            }
          });
        } else {
          this.tableData = [];
        }
      },
      deep: true,
      immediate: true
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.inner-breadcrumb {
    .breadcrumb {
        span {
            font-weight: normal;
            color: #aaa;
        }
        a {
            font-weight: normal;
            color: #aaa;
        }
        a:hover {
            color: #409eff;
        }
        .last {
            font-weight: bold !important;
            cursor: default !important;
        }
        .disable {
            cursor: default !important;
        }
    }
}
.condition-title-p {
    font-weight: 400;
    font-style: normal;
    color: #2b3b4e;
    font-size: 18px;
    margin-bottom: 15px;
}
.base-info-title {
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    color: #2b3b4e;
}
.table-style-baseinfos {
    table-layout: fixed;
    word-break: break-all;
    background-color: rgba(210, 212, 214, 1);
    box-sizing: border-box;
    border-width: 0.5px;
    border-style: solid;
    border-color: rgba(210, 212, 214, 1);
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    width: 100%;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #8896a7;
    margin-bottom: 20px;
}
.table-style-baseinfo {
    table-layout: fixed;
    word-break: break-all;
    background-color: rgba(210, 212, 214, 1);
    box-sizing: border-box;
    border-width: 0.5px;
    border-style: solid;
    border-color: rgba(210, 212, 214, 1);
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    width: 100%;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #8896a7;
    margin-bottom: 20px;
}
.table-style-baseinfos td {
    width: 25%;
    background-color: rgba(255, 255, 255, 1);
    border: none;
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #2b3b4e;
    height: 32px;
    padding: 0 10px;
}
.table-style-baseinfo td {
    width: 15%;
    background-color: rgba(255, 255, 255, 1);
    border: none;
    border-radius: 0px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
    font-weight: 401;
    font-style: normal;
    font-size: 14px;
    color: #2b3b4e;
    height: 32px;
    padding: 0 10px;
}
.table-style-baseinfos .text-right-background-color {
    background-color: #fdfeff4d;
    text-align: right;
}
.table-style-baseinfo .text-right-background-color {
    background-color: #fdfeff4d;
    text-align: right;
}
.text-center-background-color {
  background-color: #fdfeff4d;
  text-align: center;
}
.text-center-background {
  text-align: center;
}
.text-left-background-none {
    text-align: left;
}
</style>